package architecture.diagram.part;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;
import org.eclipse.gmf.runtime.emf.type.core.IElementType;

import architecture.diagram.providers.ArchitectureElementTypes;

/**
 * @generated
 */
public class ArchitecturePaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createArchitecture1Group());
	}

	/**
	 * Creates "architecture" palette tool group
	 * @generated
	 */
	private PaletteContainer createArchitecture1Group() {
		PaletteGroup paletteContainer = new PaletteGroup(
				Messages.Architecture1Group_title);
		paletteContainer.setId("createArchitecture1Group"); //$NON-NLS-1$
		paletteContainer.add(createFeature1CreationTool());
		paletteContainer.add(createFeatureIsRealicedBy2CreationTool());
		paletteContainer.add(createModule3CreationTool());
		paletteContainer.add(createModuleDepend4CreationTool());
		paletteContainer.add(createResponsability5CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createFeature1CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Feature1CreationTool_title,
				Messages.Feature1CreationTool_desc,
				Collections
						.singletonList(ArchitectureElementTypes.Feature_2003));
		entry.setId("createFeature1CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ArchitectureDiagramEditorPlugin
				.findImageDescriptor("/archtransform.edit/icons/full/obj16/Feature_8.png")); //$NON-NLS-1$
		entry.setLargeIcon(ArchitectureDiagramEditorPlugin
				.findImageDescriptor("/archtransform.edit/icons/full/obj16/Feature_8.png")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createFeatureIsRealicedBy2CreationTool() {
		LinkToolEntry entry = new LinkToolEntry(
				Messages.FeatureIsRealicedBy2CreationTool_title,
				Messages.FeatureIsRealicedBy2CreationTool_desc,
				Collections
						.singletonList(ArchitectureElementTypes.FeatureIsRealicedBy_4001));
		entry.setId("createFeatureIsRealicedBy2CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ArchitectureElementTypes
				.getImageDescriptor(ArchitectureElementTypes.FeatureIsRealicedBy_4001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createModule3CreationTool() {
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Module3CreationTool_title,
				Messages.Module3CreationTool_desc,
				Collections.singletonList(ArchitectureElementTypes.Module_2001));
		entry.setId("createModule3CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ArchitectureElementTypes
				.getImageDescriptor(ArchitectureElementTypes.Module_2001));
		entry.setLargeIcon(entry.getSmallIcon());
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createModuleDepend4CreationTool() {
		ToolEntry entry = new ToolEntry(
				Messages.ModuleDepend4CreationTool_title,
				Messages.ModuleDepend4CreationTool_desc, null, null) {
		};
		entry.setId("createModuleDepend4CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ArchitectureDiagramEditorPlugin
				.findImageDescriptor("/archtransform.edit/icons/full/obj16/implement.gif")); //$NON-NLS-1$
		entry.setLargeIcon(ArchitectureDiagramEditorPlugin
				.findImageDescriptor("/archtransform.edit/icons/full/obj16/implement.gif")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private ToolEntry createResponsability5CreationTool() {
		ArrayList<IElementType> types = new ArrayList<IElementType>(2);
		types.add(ArchitectureElementTypes.Responsability_3001);
		types.add(ArchitectureElementTypes.Responsability_2002);
		NodeToolEntry entry = new NodeToolEntry(
				Messages.Responsability5CreationTool_title,
				Messages.Responsability5CreationTool_desc, types);
		entry.setId("createResponsability5CreationTool"); //$NON-NLS-1$
		entry.setSmallIcon(ArchitectureDiagramEditorPlugin
				.findImageDescriptor("/archtransform.edit/icons/full/obj16/Responsability.png")); //$NON-NLS-1$
		entry.setLargeIcon(ArchitectureDiagramEditorPlugin
				.findImageDescriptor("/archtransform.edit/icons/full/obj16/Responsability.png")); //$NON-NLS-1$
		return entry;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				List<IElementType> elementTypes) {
			super(title, description, null, null);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List<IElementType> relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				List<IElementType> relationshipTypes) {
			super(title, description, null, null);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
